GETGRENT
Section: MINTLIB LIBRARY FUNCTIONS
(3)
Updated: 3 March 1993
Index
Return to Main Contents
NAME
getgrent, getgrgid, getgrnam, setgrent, endgrent, fgetgrent -
get group file entry
SYNOPSIS
#include <stdio.h>
#include <grp.h>
struct group *getgrent(void);
struct group *getgrgid(int gid);
struct group *getgrnam(const char *name);
void setgrent(void);
void endgrent(void);
struct group *fgetgrent(FILE *f);
DESCRIPTION
getgrent, getgrgid and getgrnam each returns a pointer to an
object containing the broken-out fields of a line in the
/etc/group file.
Each line in the file contains a "group" structure, declared
in the <grp.h> header file:
struct group
{
char *gr_name; /* name of the group */
char *gr_passwd; /* encrypted password */
gid_t gr_gid; /* numerical group ID */
char **gr_mem; /* array of member names */
};
getgrent when first called returns a pointer to the first
group structure in the file; thereafter, it returns a pointer
to the next group structure in the file; so successive calls
can be used to search the entire file.
getgrgid searches from the beginning of the file until a
numerical group ID is found matching gid is found and returns
a pointer to the particular structure in which it was found.
Thus, it cannot be found to search for several groups having
duplicate numerical group IDs.
getgrnam searches from the beginning of the file until a
group name matching name is found and returns a pointer to
the particular structure in which it was found.
If an EOF or an error is encountered on reading, getgrent,
getgrgid and getgrnam return a NULL pointer.
A call to setgrent has the effect of rewinding the group
file to allow repeated searches.
endgrent may be called to close the group file when
processing is complete.
fgetgrent returns a pointer to the next group structure in
the stream f, which matches the format of /etc/group.
FILES
/etc/group
SEE ALSO
getlogin(3),
getpwent(3)
NOTES
All information is contained in a static area, so it must
be copied if it is to be saved.
These routines cannot handle groups with over 128 members.
These routines expect the group file to be of type text,
and can therefore read both DOS and UN*X format files.
fgetgrent is not standard, but is available on System V.
For group files, there's no equivalent to putpwent.
The password field of groups is seldom used.
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- FILES
-
- SEE ALSO
-
- NOTES
-
This document was created by
man2html,
using the manual pages.
Time: 11:14:57 GMT, June 22, 2025